<?php
/*
Overmundo, cultura de todo o Brasil
Desenvolvido pela Tecnopop para o Núcleo de Idéias Movimento
Copyright (C) 2006  Núcleo de Idéias Movimento

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

*/

$nivelPagina = "desconhecido";

include('../lib/checa_login.php');
 
 
class_exists('Site') || require('../lib/class.site.php');
class_exists('Overmundo') || require('../lib/class.overmundo.php');
class_exists('Conecta') || require('../lib/class.conecta.php');
class_exists('Usuario') || require('../lib/class.usuario.php');

session_start();
if (!isset($minhaConexao))  {
	$minhaConexao = new Conecta();
}
if (!isset($meuSite)) {
	$meuSite = new Overmundo();
}

if (!isset($meuSite->linkid)) { 
	$meuSite->linkid = $minhaConexao->linkid;
}

include('../registro/valida_cpf.php');

$codUsuario = $meuSite->OvermundoProcessaFilaCheckCpf();

if($codUsuario > 0){
		
	$thisUsuario = new Usuario($meuSite->linkid, $codUsuario);
	
	$campoLimpoCpf = $thisUsuario->PegaCpf();
	
	$ResultadoConsulta = ConsultaCPF($campoLimpoCpf);
	if($ResultadoConsulta != "error"){
		$thisUsuario->SetaFilaCheckCpf(0);
		$thisUsuario->update();
		$NomeConsultaCPF = $ResultadoConsulta;
		$nomeCheckCpf = $thisUsuario->PegaNome();
		if($meuSite->OvermundoChecaCpfUsuarioNome($NomeConsultaCPF, $nomeCheckCpf)){
			//envia email de confirmacao
			$thisUsuario->EnviaConfirmacao();
		}else{
			//envia email de que houve problema com cpf
			$thisUsuario->EnviaEmailCpfInvalido();
			$thisUsuario->delete();
		}
	}else{
		//nao conseguiu consultar - problema de comunicacao, continua na fila...
	}
	
}




?>